//
//  ButtonCell.swift
//  CompareBuying
//
//  Created by 唐先才 on 16/1/28.
//  Copyright © 2016年 唐先才. All rights reserved.
//

import Foundation
import UIKit

class ButtonCell: UICollectionViewCell {
    
    @IBOutlet weak var _view: UIView!
    @IBOutlet weak var _iconView: UIImageView!
    @IBOutlet weak var _iconLabel: UILabel!
    
    func configCellWithModel(model: TxcModel) {
        guard let iconImg = model.IcoImage, name = model.IcoName else {
            print("buttonCell赋值失败")
            return
        }
        _iconView.sd_setImageWithURL(NSURL(string: iconImg))
        _iconLabel.text = name
    }
    
    static func buttonCellWithCollectionView(collectionView: UICollectionView, dataArray: NSMutableArray, indexPath: NSIndexPath)->UICollectionViewCell {
        if let buttonCell = collectionView.dequeueReusableCellWithReuseIdentifier("buttonCell", forIndexPath: indexPath) as? ButtonCell {
            if dataArray.count > 0 {
                if let model = dataArray[indexPath.row] as? TxcModel {
                    buttonCell.configCellWithModel(model)
                }
            }
            buttonCell.backgroundColor = UIColor.whiteColor()
            return buttonCell
        }
        return UICollectionViewCell()
    }
}



